#ifndef __VECTOR_H__
#define __VECTOR_H__

#include <stddef.h>
#include <assert.h>
#include "arena.h"

typedef struct vector
{
    arena_t* arena;
    size_t capacity;
    size_t length;
    size_t typelen;
    void* data;
} vector_t;

vector_t* vector_create(arena_t* a, size_t typelen, size_t capacity);
int vector_reserve(vector_t* v, size_t capacity);
int vector_append(vector_t* v, void* p);
int vector_insert(vector_t* v, int index, void* p);
int vector_erase(vector_t* v, int index);

static __inline size_t vector_length(vector_t* v)
{
    assert(v);
    return v->length;
}

static __inline void* vector_data(vector_t* v)
{
    assert(v);
    return v->data;
}

#endif /* __VECTOR_H__ */
